package qianmian;

public class Student extends Person {

    private Course selectedCourse;


    public Student(String id, String name, String sex) {
        super(id, name, sex); // 初始化
    }

    
    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println("学生【" + super.name + "】选课成功：" + course.getName());
    }


    public void dropCourse() {
        if (this.selectedCourse != null) {
            System.out.println("学生【" + super.name + "】退课成功：" + this.selectedCourse.getName());
            this.selectedCourse = null;
        } else {
            System.out.println("学生【" + super.name + "】暂无选课记录，无需退课");
        }
    }


    public void printWorksheet() {
        System.out.println("\n===== 学生课表 =====");
        System.out.println("学生编号：" + super.id);
        System.out.println("学生姓名：" + super.name);
        System.out.println("学生性别：" + super.sex);
        
        if (this.selectedCourse != null) {
            System.out.println("课程编号：" + this.selectedCourse.getId());
            System.out.println("课程名称：" + this.selectedCourse.getName());
            System.out.println("上课地点：" + this.selectedCourse.getLocation());
            System.out.println("上课时间：" + this.selectedCourse.getTime());
            System.out.println("授课教师：" + this.selectedCourse.getTeacher().getName());
        } else {
            System.out.println("选课状态：暂无选课记录");
        }
        System.out.println("====================\n");
    }


    public Course getSelectedCourse() {
        return selectedCourse;
    }
}
